﻿using System;
using System.Collections.Generic;

using SharedGenomics.Core;
using SharedGenomics.Workbench.Core;
using SharedGenomics.Domain;

namespace SharedGenomics.Workbench.Services
{
    public class DataSetRepository : WCFClientHost, IDataSetRepository
    {
        public virtual void AddDataSet(DataSetInfo dataSetInfo)
        {
            dataSetInfo.ThrowIfNull("dataSet");
            this.ExecuteProxyContract<DataService.IDataService>(ds => ds.CreateDataSet(dataSetInfo));
        }

        public virtual Maybe<EntityInfo[]> GetDataSetInfos()
        {
            return this.ExecuteProxyContract<DataService.IDataService, EntityInfo[]>(ds => ds.GetUserDataSetInfos()).Just();
        }

        public virtual Maybe<IEnumerable<DataSetSummary>> GetDataSetSummaries()
        {
            var summaries = this.ExecuteProxyContract<DataService.IDataService, DataSetSummary[]>(ds => ds.GetUserDataSetSummaries());
            return new Maybe<IEnumerable<DataSetSummary>>(summaries);
        }
    }
}
